﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.IO;
using System.Windows.Forms;

namespace SharePointCustomizer
{
    public partial class NewProject : Form
    {
        public string projectPath;
        /// <summary>
        /// 
        /// </summary>
        public NewProject()
        {
            InitializeComponent();
        }
        /// <summary>
        /// btnBrowse Click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnBrowse_Click(object sender, EventArgs e)
        {
            folderBrowserDialog.ShowDialog();
            txtProjPath.Text = folderBrowserDialog.SelectedPath;
        }
        /// <summary>
        /// btnCancel Click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }
        /// <summary>
        /// btnSave Click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click(object sender, EventArgs e)
        {
            CreateNewProject();
        }
        /// <summary>
        /// Create New Project
        /// </summary>
        private void CreateNewProject()
        {
            try
            {
                if (txtProjPath.Text.Trim() != "")
                {
                    string path = txtProjPath.Text + "\\" + txtProjName.Text;
                    Directory.CreateDirectory(path);
                    Directory.CreateDirectory(path + "\\images");
                    Directory.CreateDirectory(path + "\\css");
                    MainForm main = (MainForm)this.Owner;
                    projectPath = path;
                    main.projectPath = this.projectPath;
                    this.Dispose();
                }
                else
                {
                    MessageBox.Show("You must selelct location and project name ", "SharePoint Customizer");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

           
        }
    }
}
